<?php
// +----------------------------------------------------------------------
// | YCMX  [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2023 https://www.fastadmin.net All rights reserved.
// +----------------------------------------------------------------------
// | Author: 王斌
// +----------------------------------------------------------------------

namespace app\admin\model\ycmx;

use app\admin\model\Admin;
use think\Model;
use traits\model\SoftDelete;

class Ycmx extends Model
{

    use SoftDelete;



    // 表名
    protected $name = 'ycmx';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'status_text'
    ];


    public function getStatusList()
    {
        return ['未结账' => __('未结账'), '已结账' => __('已结账')];
    }
    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function tadmin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id')->setEagerlyType(0);
        
    }
}
